package com.linwen.junit;


import jdk.nashorn.internal.ir.annotations.Ignore;
import org.junit.*;

public class CalculatorTest {

	private Calculator cal;

	@BeforeClass
	public static void setupClass() {
		System.out.println("start! only once execute");
	}

	@AfterClass
	public static void shutdoemClass() {
		System.out.println("end! only once execute");
	}

	@Before
	public void setUp() {
		cal = new Calculator();
		cal.setX(15);
		cal.setY(5);
		System.out.println("创建Calculator对象，开始测试");
	}

	@After
	public void shutDown() {
		cal = null;
		System.out.println("测试方法结束");
	}

	@Test
	public void testAdd() {
		int z = cal.add();
		System.out.println(cal.getX() + " addd  " + cal.getY());
		Assert.assertEquals(20, z);
	}

	@Test
	public void testSubstract() {
		int z = cal.substract();
		Assert.assertEquals(10, z);
	}

	@Ignore
	@Test
	public void testMulitipy() {
		int z = cal.mulitipy();
		Assert.assertEquals(75, z);
	}

	@Test
	public void testDivide() {
		int z = cal.divide();
		Assert.assertEquals(3, z);
	}
}
